<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户登陆页面</title>
<style type="text/css">
   form{
      margin:10px;
   }
   div{
      margin:0.1px;
   }
   span{
      margin:1px;
   }
   /* #forgetPwd{
      margin:1px;
   } */
   
</style>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
<body>
<!-- <div id="login"> -->
 	<form target="_blank" class="form-horizontal">
 	  <div class="form-group">
 	    <div class="col-sm-3">
 	     <input type="text" name='uname' class='text uname form-control'   placeholder="通行昵称/手机号/邮箱"/>
 	    </div> 
 	  </div>
 	  <div class="form-group">
 	    <div class="col-sm-3">
 	     <input type="password" name='password' class='text password form-control'  placeholder="请输入密码"/>
 	    </div>
 	  </div>
 	  <div class="form-group">
 	     <!-- 验证码 -->
 	    <div class="col-sm-3"> 
 	     <input type="text" id="code" name="code" class="form-control"  placeholder="验证码"/>
 	    </div>
 	    <div> 
 	     <img id="imgObj" alt="验证码" src="validateCode" onclick="changeImg()"/>
         <a href="#" onclick="changeImg()">换一张</a>
        </div>  
      <!-- 验证码结束 -->
      </div>
      <div class="form-group" >
        <div class="col-sm-5">
          <input type="submit" name='sub' class="btn btn-primary btn-lg active" id='btn' style="width:220px" value="登陆"  />
          <a href="updatePwd.jsp" class="btn btn-primary active" role="button" onclick="updatePwd()">忘记密码</a>
          <!-- <button type="button" class="btn btn-link">忘记密码</button> -->
        </div>
          
      </div>
    </form>
<!--  </div> -->
</body>


<script type="text/javascript">
   $(function(){
	   $("#btn").click(function(){
		   var uname=$(".uname").val();
		   var uaccount=$(".uname").val();
		   var phone=$(".uname").val();
		   var email=$(".uname").val();
		   var password=$(".password").val();
		   var code=$("#code").val();	
		   alert(code);
		   /* 判断用户名和密码是否非空 */
		   if(uname==""||uaccount==""||phone==""||email==""||password==""||password==""){
				  alert("用户名或密码不能为空！");
			   } 
		   
		   $.ajax({
			   type:'post',
			   url:'query2',
			   dataType:'json', 
			   data:{
				   uname:uname,
				   uaccount:uaccount,
				   phone:phone,
				   email:email,
				   password:password,
				   code:code
			   } , 
			   success:function(result){	
				           alert(result);
  					        if(result==false){
							   alert("输入错误，请重新输入！");
						   }else{
							   window.location.href="success.jsp";
						   } 
			   } 
		   });
	   });
	   
	    
   });
</script>

<script type="text/javascript">
//刷新图片  
function changeImg() {  
    var imgSrc = $("#imgObj");  
    var src = imgSrc.attr("src");  
    imgSrc.attr("src", changeUrl(src));  
}  
//为了使每次生成图片不一致，即不让浏览器读缓存，所以需要加上时间戳  
function changeUrl(url) {  
    var timestamp = (new Date()).valueOf();  
    var index = url.indexOf("?",url);  
    if (index > 0) {  
        url = url.substring(index, url.indexOf(url, "?"));  
    }  
    if ((url.indexOf("&") >= 0)) {  
        url = url + "×tamp=" + timestamp;  
    } else {  
        url = url + "?timestamp=" + timestamp;  
    }  
    return url;  
}  
</script>
</html>